package tcss543.singlehelper;

//import java.io.IOException;
//import java.util.ArrayList;

import tcss543.DeviceGraph;

//import java.util.*;

public class GraphConstructor {
	
	
	
	public int[][] GetResiduegraph(DeviceGraph graph)
	{
		int[] requestors = graph.getR();
		int[] helpers = graph.getH();
		
		int[][] residuegraph = new int[requestors.length][helpers.length];
		
	    
		
		return residuegraph;
	}
	
	public int[][] GetAdjacentgraph(DeviceGraph graph)
	{
		int[] requestors = graph.getR();
		int[] helpers = graph.getH();
		
		int[][] adjacentgraph = new int[helpers.length][];
		
		final int INF = 100000;
		
		int[][] reqNeighbors = graph.getNeighbors();
		
		for(int i = 0; i < requestors.length; i++)
		{
			adjacentgraph[i] = new int[helpers.length];
			
			for(int j = 0; j < helpers.length; j++)
			{
				adjacentgraph[i][j] = -INF;
			}
		}
		
		for(int i = 0; i < requestors.length; i++)
		{
			
			for(int j = 0; j < reqNeighbors[i].length; j++)
			{
				adjacentgraph[i][j] = helpers[reqNeighbors[i][j]];
			}
		}
				
		return adjacentgraph;
	}
	
	public SHelper[] GetHelpers (DeviceGraph graph)
	{
		SHelper[] helpers = new SHelper[graph.getH().length];
		
		for (int i = 0; i < graph.getH().length; i++) {
			SHelper h = new SHelper();
			h.j = i;
			h.capacity = graph.getH()[i];
			helpers[i] = h;
		}
			
		return  helpers; 
	}
	
	public SRequestor[] GetRequesters (DeviceGraph graph)
	{
		
        SRequestor[] requestors = new SRequestor[graph.getR().length];
		
		for (int i = 0; i < graph.getR().length; i++) {
			
			SRequestor r = new SRequestor();
			r.i = i;
			r.unitsOfWork = graph.getR()[i];
			r.done = false ;
			
			requestors[i] = r;
		}
		return requestors;
	}
    
}
